<?php
class Display
{

	private $sidebar;
	private $base;

	function __construct()
	{
		$this->base = SmitBase::getInstance();
	}

	function top()
	{

	$title = (defined('THIS')) ? THIS : 'Dashboard';

	echo <<<EOL
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml">
		<head>
			<meta http-equiv="Content-type" content="text/html; charset=utf-8" />

			<title>Swixs: {$title}</title>
			<style type="text/css">
				*
				{
					padding: 0;
					margin: 0;
				}
				:focus
				{
					outline: 0;
				}
				img
				{
					border: none;
				}
				body
				{
					font: 13px "Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif;
					background: #2C3536 url('images/bg.png') repeat-x;
					line-height: 30px;
					color: #555;
				}
				h1, h2, h3, h4, h5, h6, address {
					font-family: "Lucida Grande", "Lucida Sans", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif;
				}
				strong, em, b, i {
					font-family: "Lucida Grande", "Lucida Sans", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif;
				}
				a {
					color: #9b9b9b;
					outline: 0;
					text-decoration: none;
				}
				h2
				{
					color: #FFF;
					background: #0080E3 url('images/grad.png') repeat-x;
					margin: -30px -30px 0 -30px;
					padding: 20px;
					margin-bottom: 27px;
					font: 23px Georgia, Times, "Times New Roman", serif;
					font-weight: normal;
				}
				a
				{
					color: #004ba2;
					text-decoration: none;
				}
				a:hover
				{
					color: #555;
				}
				#wrapper
				{
					width: 990px;
					margin: 40px auto 0 auto;
				}
				#container
				{
					width: 100%;
					margin-top: 50px;
					background: #151E1F url('images/tile.png');
				}
				input, textarea
				{
					font: 13px "Lucida Grande", "Lucida Sans", Verdana, Arial, Helvetica, sans-serif;
				}
				input.text, textarea
				{
					background: #f5f5f5;
					border: 1px solid #D0D0D0;
					color: #666;
					padding: 12px;
					margin-bottom: 20px;
				}
				.notes
				{
					width: 248px;
					border: 1px solid #C0D0E2;
					background: #F0F5FA;
				}
				.notice 
				 {  
					background-color: #fff9d7;  
					width: 93%;
					margin-bottom: 2%;
					border: 1px solid #e2c822;  
					float: left;
					color: #555;  
					padding: 3%;  
					font-size: 13px;  
				 }
				 .message
				 {  
					background-color: #f7f7f7;
					width: 100%;
					border: 1px solid #cccccc;
					float: left;
					color: #333;  
					padding: 10px;  
					margin: 20px;
					font-size: 13px;   
				 } 
				h3
				{
					color: #0063C7;
					font: 23px Georgia, Times, "Times New Roman", serif;
				}
				 .wrap
				 {
					background: #FFF;
					font-size: 11px;
					border: 1px solid #D1D1D1;
					width: 87%;
					margin: 5px 0 20px 0;
					padding: 10px;
				 }
				 .wrap p, p.row
				 {
					border-bottom: 1px solid #CCC;
					padding: 10px;
					text-align: right;
				 }
				 .wrap p:last-child
				 {
					border: 0;
					padding-bottom: 0;
				 }
				 .wrap label, label.caption
				 {
					color: #0080E3;
					font-weight: 700;
					float: left;
				 }
				 .clearing
				 {
					clear: both;
				 }
				 .logo
				 {
					margin: 40px 0 0 40px;
				 }
				 .left
				 {
					float: left;
				 }
				 .col
				 {
					float: left;
					width: 50%;
				 }
				 #main
				 {
					float: right;
					width: 630px;
					background: #FFF;
					padding: 30px;
				 }
				 #sidebar
				 {
					float: left;
					width: 300px;
					font: italic 14px Georgia, 'Nimbus Roman No9 L', norasi, rekha, serif;
					background: #151E1F;
				 }
				 #sidebar ul.nav
				 {
					list-style: none;
					font-size: 16px;
					border-bottom: 1px solid #2a3d3f;
					width: 100%;
					background: #151E1F;
				 }
				 #sidebar ul.nav li:first-child
				 {
					border-top: 0;
				 }
				 #sidebar ul.nav li.nav
				 {
					border-bottom: 1px solid #0d1213;
					border-top: 1px solid #2a3d3f;
					color: #AAA;
					padding: 30px;
					display: block;
				 }
				 ul.nav li.sub
				 {
					border: 0;
					padding: 30px;
					display: block;
					background: #213032;
				 }
				 li.sub ul
				 {
					list-style-type: none;
				 }
				 li.sub ul li
				 {
					font: 13px "Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif;
					margin-bottom: 4px;
				 }
				 #sidebar ul.nav li a
				 {
					color: #AAA;
					text-decoration: none;
				 }
				 #sidebar ul.nav li a:hover
				 {
					color: #FFF;
				 }
				 div.row
				 {
					display: block;
				 }
				.button
				{
					border: 1px solid #558aa9;
					padding: 5px;
					background: #d8dfea;
					font-weight: 700;
					color: #666;
				}
			</style>
			<script type="text/javascript" src="js/jquery.js">	</script>
			<script type="text/javascript" src="js/functions.js">	</script>

		</head>
		<body>
			<div id="wrapper">
			<img src="images/logo.png" class="logo" alt="Swixs Matterhorn" />
			<div id="container">
			<div id="main">
			<h2>Dashboard &rarr; {$title}</h2>
EOL;
	}
	function bottom()
	{
	echo '<div class="clearing"></div></div><div id="sidebar">';
	echo $this->sidebar;
	echo '</div><div class="clearing"></div></div></div></body></html>';
	}
	function login()
	{
	
	$username = $this->base->lib->inputVal('username');
	if($username == NULL)
	{
		$username = 'Username';
	}
	echo <<<EOL
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml">
		<head>
			<meta http-equiv="Content-type" content="text/html; charset=utf-8" />

			<title>Smit: Authentication Required</title>
			<style type="text/css">
				*
				{
					padding: 0;
					margin: 0;
				}
				:focus
				{
					outline: 0;
				}
				img
				{
					border: none;
				}
				body
				{
					font: italic 14px Georgia, 'Nimbus Roman No9 L', norasi, rekha, sans-serif;
					background: #2C3536 url('images/bg.png') repeat-x;
					color: #555;
				}
				h2
				{
					color: #FFF;
					font-size:21px;
					margin: -30px -30px 0 -30px;
					padding: 20px;
					background: #0080E3 url('images/grad.png') repeat-x;
					margin-bottom: 27px;
					font-weight: normal;
				}
				a
				{
					color: #004ba2;
					text-decoration: none;
				}
				a:hover
				{
					color: #555;
				}
				#wrapper
				{
					width: 418px;
					margin: 40px auto;
				}
				#container
				{
					margin-top: 90px;
					background: #FFF;
					padding: 30px;
					width: 418px;
				}
				input
				{
					font: italic 16px Georgia, 'Nimbus Roman No9 L', norasi, rekha, sans-serif;
				}
				input.text
				{
					background: #f5f5f5;
					border: 1px solid #D0D0D0;
					color: #666;
					padding: 12px;
					margin-bottom: 20px;
				}
				.button
				{
					border: 1px solid #AAA;
					padding: 10px;
					background: #DDD;
					font-size: 15px;
					width: 100px;
					float: left;
					color: #666;
				}
				.notice 
				 {  
					background-color: #fff9d7;  
					border: 1px solid #e2c822;  
					color: #555;  
					padding: 10px;  
					margin-bottom: 20px;
					font-size: 13px;  
					font-weight: bold;  
				 }
				 .message
				 {  
					background-color: #0E3350;  
					border: 1px solid #2571AB;  
					color: #EBCD4E;  
					padding: 10px;  
					margin-bottom: 20px;
					font-size: 13px;  
					font-weight: bold;  
				 } 
				 .clearing
				 {
					clear: both;
				 }
				 .img
				 {
					float: right;
				 }
				 .left
				 {
					float: left;
				 }
			</style>

		</head>
		<body>
			<div id="wrapper">
				<img src="images/logo.png" alt="Smit" />
				<div id="container">
				<h2>Smit &rarr; Dashboard</h2>
				<div class="notice">There has been an error authorising you</div>
				<div class="left">
				<form action="index.php" method="post">
					<p><input type="text" class="text" name="username" onclick="if(this.value == 'Username') { this.value = ''; }" onblur="if(this.value == '') { this.value = 'Username'; }" value="{$username}" size="30" /></p>
					<p><input type="password" class="text" name="password" size="30" /></p>
					<input type="submit" class="button" name="login" value="Login" />
				</form>
				</div>
				<div class="clearing"></div>
				</div>
			</div>
		</body>
	</html>
EOL;
	}

	function column($contents)
	{
		echo'<div class="col">';
		echo $contents;
		echo'</div>';
	}

	function box($title, $contents)
	{
		$build = '<h3>' . $title . '</h3>' . chr(10);
		$build .= '<div class="wrap">' . chr(10);
		$build .= $contents . chr(10);
		$build .= '</div>' . chr(10);
		return $build;
	}

	function form($name, $action, $contents)
	{
		$build = '<form action="' . $action . '" name ="' . $name . '" method="post">' . chr(10);
		$build .= $contents . chr(10);
		$build .= '</form>' . chr(10);
		return $build;
	}

	function textarea($name, $content = '', $extra = array())
	{
		$attrib = '';
		foreach($extra as $key => $value)
		{
			$attrib .= ' ' . $key . '="' . $value . '"';
		}
		$build = '<textarea id="' . $name . '" name="' . $name . '" rows="10" cols="10"' . $attrib . '>' . chr(10);
		$build .= $content;
		$build .= '</textarea>' . chr(10);
		return $build;
	}

	function submit($value)
	{
		$build = '<input type="submit" onclick="return false;" class="button" value="' . $value . '" name="submit" />' . chr(10);
		return $build;
	}

	function item($label, $value)
	{
		return '<p><label>' . $label . '</label>' . $value . '</p>' . chr(10);
	}

	function item2($label, $value)
	{
		echo '<p class="row"><label class="caption">' . $label . '</label>' . $value . '</p>' . chr(10);
	}

	function link($controller)
	{
		global $loader;
		$loader->link();
	}

	function sidebar($items)
	{
		global $loader;
		$build = '<ul class="nav">' . chr(10);
		$i = 1;
		foreach($items as $name => $children)
		{
			$build .= '<li class="nav" onclick="collapse(\'cat-' . $i . '\');return false;"><a href="' . $loader->uri($children['uri']) . '">' . htmlentities($name, ENT_QUOTES, 'UTF-8') . '</a></li>';
			$build .='<li class="sub" id ="cat-' . $i . '"><ul>';
			foreach($children as $title => $uri)
			{
				if($title != 'uri')
				{
					$build .= '<li><a href="' . $loader->uri($uri) . '">' . htmlentities($title, ENT_QUOTES, 'UTF-8') . '</a></li>';
				}
			}
			$build .= '</ul></li>';
			$i++;
		}
		$build .= '</ul>';
		
		$this->sidebar = $build;
	}

}
?>